#!/usr/bin/env node
const shell = require("shelljs");
const jsonfile = require("jsonfile");
const chalk = require("chalk");
const file = `${__dirname}/default.json`;
let jsonObj = jsonfile.readFileSync(file);
//设置命令行参数
const argv = require("yargs")
	.option("install", {
		alias: "i",
		describe: "npm install *** && wam install ***",
		type: "string"
	})
	.option("bdefalut", {
		alias: "w",
		describe: '闹着玩的,啥也不干',
		type: "string"
	})
	.usage("Usage: ssgit [options] or ssgit message[string]")
	.example(" ssgit fix:change number ")
	.alias("h", "help")
	.alias("v", "version").argv;


//输出命令到控制台
// \d+(\.\d+){0,2}
// /^\d+(\.\d+)+$/
const re =  /@\d+(\.\d+){2}/;
let package = argv.install
if(!re.exec(argv.install)){
	package = `${package}@latest`
}
 const order = `(npm install ${package} --save &&
				wam install ${package} -D&&
				npm run init)
				`
				console.log(package, 'package')
// shell.exec(order,(error, stdout, stderr)=>{
// 	console.log(error, stdout, stderr)
// })
// console.log('22222', chalk.green(order))
//执行命令

// jsonfile.writeFileSync(file, jsonObj);
